<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  
  <title>Hexo</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="第二十章Tomcat01 Web相关概念  软件架构   C&#x2F;S：客户端&#x2F;服务器端    B&#x2F;S：浏览器&#x2F;服务器端        资源分类   静态资源：所有用户访问后，得到的结果都是一样的，称为静态资源。静态资源可以直接被浏览器解析。   如： Html、Css、JavaScript        动态资源:每个用户访问相同资源后，得到的结果可能不一样，称为动态资源。动态资源被访问后，需要先转换">
<meta property="og:type" content="article">
<meta property="og:title" content="Hexo">
<meta property="og:url" content="https://goofyer.gitee.io/notes-on-computer-expertise/2021/12/20/Java/%E7%AC%AC%E4%BA%8C%E5%8D%81%E7%AB%A0Tomcat/index.html">
<meta property="og:site_name" content="Hexo">
<meta property="og:description" content="第二十章Tomcat01 Web相关概念  软件架构   C&#x2F;S：客户端&#x2F;服务器端    B&#x2F;S：浏览器&#x2F;服务器端        资源分类   静态资源：所有用户访问后，得到的结果都是一样的，称为静态资源。静态资源可以直接被浏览器解析。   如： Html、Css、JavaScript        动态资源:每个用户访问相同资源后，得到的结果可能不一样，称为动态资源。动态资源被访问后，需要先转换">
<meta property="og:locale" content="en_US">
<meta property="article:published_time" content="2021-12-19T17:35:42.302Z">
<meta property="article:modified_time" content="2021-12-19T17:35:43.191Z">
<meta property="article:author" content="John Doe">
<meta name="twitter:card" content="summary">
  
    <link rel="alternate" href="/notes-on-computer-expertise/atom.xml" title="Hexo" type="application/atom+xml">
  
  
    <link rel="shortcut icon" href="/notes-on-computer-expertise/favicon.png">
  
  
    
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/typeface-source-code-pro@0.0.71/index.min.css">

  
  
<link rel="stylesheet" href="/notes-on-computer-expertise/css/style.css">

  
    
<link rel="stylesheet" href="/notes-on-computer-expertise/fancybox/jquery.fancybox.min.css">

  
<meta name="generator" content="Hexo 5.4.0"></head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/notes-on-computer-expertise/" id="logo">Hexo</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/notes-on-computer-expertise/">Home</a>
        
          <a class="main-nav-link" href="/notes-on-computer-expertise/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/notes-on-computer-expertise/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="https://goofyer.gitee.io/notes-on-computer-expertise"></form>
      </div>
    </div>
  </div>
</header>

      <div class="outer">
        <section id="main"><article id="post-Java/第二十章Tomcat" class="h-entry article article-type-post" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
  <div class="article-meta">
    <a href="/notes-on-computer-expertise/2021/12/20/Java/%E7%AC%AC%E4%BA%8C%E5%8D%81%E7%AB%A0Tomcat/" class="article-date">
  <time class="dt-published" datetime="2021-12-19T17:35:42.302Z" itemprop="datePublished">2021-12-20</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
    <div class="e-content article-entry" itemprop="articleBody">
      
        <h2 id="第二十章Tomcat"><a href="#第二十章Tomcat" class="headerlink" title="第二十章Tomcat"></a>第二十章Tomcat</h2><h3 id="01-Web相关概念"><a href="#01-Web相关概念" class="headerlink" title="01 Web相关概念"></a>01 Web相关概念</h3><ul>
<li><ol>
<li><p>软件架构</p>
<ul>
<li><ol>
<li>C/S：客户端/服务器端</li>
</ol>
</li>
<li><ol>
<li>B/S：浏览器/服务器端</li>
</ol>
</li>
</ul>
</li>
</ol>
</li>
<li><ol>
<li><p>资源分类</p>
<ul>
<li><ol>
<li><p>静态资源：所有用户访问后，得到的结果都是一样的，称为静态资源。静态资源可以直接被浏览器解析。</p>
<ul>
<li><ul>
<li>如： Html、Css、JavaScript</li>
</ul>
</li>
</ul>
</li>
</ol>
</li>
<li><ol>
<li><p>动态资源:每个用户访问相同资源后，得到的结果可能不一样，称为动态资源。动态资源被访问后，需要先转换为静态资源，再返回给浏览器。</p>
<ul>
<li><ul>
<li>如：servlet/jsp、php、asp …</li>
</ul>
</li>
</ul>
</li>
</ol>
</li>
</ul>
</li>
</ol>
</li>
<li><ol>
<li><p>网络通信三要素</p>
<ul>
<li><ol>
<li>IP：电子设备(计算机)在网络中的唯一标识。</li>
</ol>
</li>
<li><ol>
<li>端口：应用程序在计算机中的唯一标识，端口号取值范围：0~65536。</li>
</ol>
</li>
<li><ol>
<li><p>传输协议：规定了数据传输的规则。</p>
<ul>
<li><ol>
<li>基础协议：</li>
</ol>
<ul>
<li><ol>
<li>tcp：安全协议，三次握手，速度稍慢。</li>
</ol>
</li>
<li><ol>
<li>udp：不安全协议，速度快。</li>
</ol>
</li>
</ul>
</li>
</ul>
</li>
</ol>
</li>
</ul>
</li>
</ol>
</li>
<li><p>web服务器软件</p>
<ul>
<li><ul>
<li>服务器：安装了服务器软件的计算机</li>
</ul>
</li>
<li><ul>
<li><p>服务器软件：接收用户的请求、处理请求、做出响应。</p>
<ul>
<li><ul>
<li>web服务器软件：接收用户的请求、处理请求、做出响应。</li>
</ul>
</li>
<li><ul>
<li>在web服务器软件中，可以部署web项目，让用户通过浏览器来访问这些项目。</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li><ul>
<li>web容器</li>
</ul>
</li>
<li><ul>
<li><p>常见的java相关的web服务器软件：</p>
<ul>
<li><ul>
<li>webLogic：oracle公司，大型的JavaEE服务器，支持所有的JavaEE规范，收费的。</li>
</ul>
</li>
<li><ul>
<li>webSphere：IBM公司，大型的JavaEE服务器，支持所有的JavaEE规范，收费的。</li>
</ul>
</li>
<li><ul>
<li>JBOSS：JBOSS公司，大型的JavaEE服务器，支持所有的JavaEE规范，收费的。</li>
</ul>
</li>
<li><ul>
<li>Tomcat：Apache基金组织，中小型的JavaEE服务器，仅仅支持少量的JavaEE规范servlet/jsp。开源的，免费的。</li>
</ul>
</li>
<li><ul>
<li>JavaEE：Java语言在企业级开发中使用的技术规范的总和，一共规定了13项大的规范。</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<h3 id="02-Tomcat基本操作-web服务器软件"><a href="#02-Tomcat基本操作-web服务器软件" class="headerlink" title="02 Tomcat基本操作(web服务器软件)"></a>02 Tomcat基本操作(web服务器软件)</h3><ul>
<li><ol>
<li>下载：<a target="_blank" rel="noopener" href="http://tomcat.apache.org/">http://tomcat.apache.org/</a></li>
</ol>
</li>
<li><ol>
<li><p>安装：解压压缩包即可。</p>
<ul>
<li><ul>
<li>注意：安装目录建议不要有中文和空格。</li>
</ul>
</li>
</ul>
</li>
</ol>
</li>
<li><ol>
<li>卸载：删除目录就行了。</li>
</ol>
</li>
<li><ol>
<li><p>启动：</p>
<ul>
<li><ul>
<li>bin/startup.bat ,双击运行该文件即可</li>
</ul>
</li>
<li><ul>
<li><p>访问：浏览器输入：</p>
<ul>
<li><a href="http://localhost:8080（访问自己）">http://localhost:8080（访问自己）</a></li>
<li><a href="http://别人的ip:8080（访问别人）">http://别人的ip:8080（访问别人）</a></li>
</ul>
</li>
</ul>
</li>
<li><ul>
<li><p>可能遇到的问题：</p>
<ul>
<li><ol>
<li><p>黑窗口一闪而过：</p>
<ul>
<li><ul>
<li>原因： 没有正确配置JAVA_HOME环境变量</li>
</ul>
</li>
<li><ul>
<li>解决方案：正确配置JAVA_HOME环境变量</li>
</ul>
</li>
</ul>
</li>
</ol>
</li>
<li><ol>
<li><p>启动报错：</p>
<ul>
<li><ol>
<li>暴力：找到占用的端口号，并且找到对应的进程，杀死该进程。</li>
</ol>
<ul>
<li><ul>
<li>netstat -ano</li>
</ul>
</li>
</ul>
</li>
<li><ol>
<li>温柔：修改自身的端口号。</li>
</ol>
<ul>
<li><ul>
<li>conf/server.xml</li>
</ul>
</li>
<li><ul>
<li><Connector port="8888" protocol="HTTP/1.1"

- connectionTimeout="20000"
- redirectPort="8445" />
</li>
</ul>
</li>
</ul>
</li>
<li><ul>
<li>一般会将tomcat的默认端口号修改为80。80端口号是http协议的默认端口号。</li>
</ul>
</li>
<li><ul>
<li>好处：在访问时，不用输入端口号</li>
</ul>
</li>
</ul>
</li>
</ol>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ol>
</li>
<li><ol>
<li><p>关闭</p>
<ul>
<li><ol>
<li><p>正常关闭：</p>
<ul>
<li><ul>
<li>bin/shutdown.bat</li>
</ul>
</li>
<li><ul>
<li>ctrl+c</li>
</ul>
</li>
</ul>
</li>
</ol>
</li>
<li><ol>
<li><p>强制关闭：</p>
<ul>
<li><ul>
<li>点击启动窗口的×</li>
</ul>
</li>
</ul>
</li>
</ol>
</li>
</ul>
</li>
</ol>
</li>
<li><ol>
<li><p>配置</p>
<ul>
<li><ul>
<li><p>部署项目的方式：</p>
<ul>
<li><ol>
<li><p>直接将项目放到webapps目录下即可。</p>
<ul>
<li><ul>
<li>/hello：项目的访问路径—&gt;虚拟目录</li>
</ul>
</li>
<li><ul>
<li>简化部署：将项目打成一个war包，再将war包放置到webapps目录下。</li>
</ul>
</li>
<li><ul>
<li>war包会自动解压缩</li>
</ul>
</li>
</ul>
</li>
</ol>
</li>
<li><ol>
<li><p>配置conf/server.xml文件</p>
<ul>
<li>在<Host>标签体中配置</li>
<li><Context docBase="D:\hello" path="/hehe" /></li>
<li><ul>
<li>docBase:项目存放的路径</li>
</ul>
</li>
<li><ul>
<li>path：虚拟目录</li>
</ul>
</li>
</ul>
</li>
</ol>
</li>
<li><ol>
<li><p>在conf\Catalina\localhost创建任意名称的xml文件。在文件中编写：</p>
<ul>
<li><Context docBase="D:\hello" /></li>
<li><ul>
<li>虚拟目录：xml文件的名称</li>
</ul>
</li>
</ul>
</li>
</ol>
</li>
</ul>
</li>
</ul>
</li>
<li><ul>
<li><p>项目形式2种，静态项目和动态项目：</p>
<ul>
<li><ul>
<li>静态项目：存放静态资源，html、css、js，图片\文本\视频…</li>
</ul>
</li>
<li><ul>
<li><p>动态项目：静态资源+动态资源(servlet\jsp…)</p>
<ul>
<li><ul>
<li><p>目录结构</p>
<ul>
<li><ul>
<li><p>java动态项目的目录结构：</p>
<ul>
<li><p>— 项目的根目录</p>
<ul>
<li><p>— WEB-INF目录：</p>
<ul>
<li>— web.xml：web项目的核心配置文件</li>
<li>— classes目录：放置字节码文件的目录</li>
<li>— lib目录：放置依赖的jar包</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ol>
</li>
<li><p>Tomcat 目录结构</p>
</li>
<li><p>Tomcat 启动</p>
<ul>
<li>本机:tomcat默认端口号 —— <a target="_blank" rel="noopener" href="http://127.0.0.1:8080/">http://127.0.0.1:8080/</a>   <a target="_blank" rel="noopener" href="http://localhost:8080/">http://localhost:8080/</a></li>
<li>使用电脑ip地址，访问tomcat。</li>
</ul>
</li>
<li><p>tomcat_启动问题分析</p>
</li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="https://goofyer.gitee.io/notes-on-computer-expertise/2021/12/20/Java/%E7%AC%AC%E4%BA%8C%E5%8D%81%E7%AB%A0Tomcat/" data-id="cl403sxr9001mf8vuaf75boew" data-title="" class="article-share-link">Share</a>
      
      
      
    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/notes-on-computer-expertise/2021/12/20/Java/%E7%AC%AC%E4%BA%8C%E5%8D%81%E4%B8%80%E7%AB%A0Servlet%E5%92%8CHTTP%E8%AF%B7%E6%B1%82%E5%8D%8F%E8%AE%AE/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          (no title)
        
      </div>
    </a>
  
  
    <a href="/notes-on-computer-expertise/2021/12/20/Java/%E7%AC%AC%E5%8D%81%E4%B9%9D%E7%AB%A0XML/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title"></div>
    </a>
  
</nav>

  
</article>


</section>
        
          <aside id="sidebar">
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Categories</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/notes-on-computer-expertise/categories/C-%E5%B7%A5%E5%85%B7/">C#工具</a></li><li class="category-list-item"><a class="category-list-link" href="/notes-on-computer-expertise/categories/C-%E5%B7%A5%E5%85%B7/">C++工具</a></li><li class="category-list-item"><a class="category-list-link" href="/notes-on-computer-expertise/categories/Mysql/">Mysql</a></li><li class="category-list-item"><a class="category-list-link" href="/notes-on-computer-expertise/categories/blender/">blender</a></li><li class="category-list-item"><a class="category-list-link" href="/notes-on-computer-expertise/categories/linux/">linux</a></li><li class="category-list-item"><a class="category-list-link" href="/notes-on-computer-expertise/categories/manim/">manim</a></li><li class="category-list-item"><a class="category-list-link" href="/notes-on-computer-expertise/categories/spring/">spring</a></li><li class="category-list-item"><a class="category-list-link" href="/notes-on-computer-expertise/categories/vba%E5%9F%BA%E7%A1%80%E6%93%8D%E4%BD%9C/">vba基础操作</a></li><li class="category-list-item"><a class="category-list-link" href="/notes-on-computer-expertise/categories/%E5%88%9B%E9%80%A0%E6%A8%A1%E5%BC%8F/">创造模式</a></li><li class="category-list-item"><a class="category-list-link" href="/notes-on-computer-expertise/categories/%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F/">操作系统</a></li><li class="category-list-item"><a class="category-list-link" href="/notes-on-computer-expertise/categories/%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86/">操作系统基础知识</a></li><li class="category-list-item"><a class="category-list-link" href="/notes-on-computer-expertise/categories/%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%E5%BC%80%E5%8F%91/">操作系统开发</a></li><li class="category-list-item"><a class="category-list-link" href="/notes-on-computer-expertise/categories/%E6%95%B0%E5%AD%A6/">数学</a></li><li class="category-list-item"><a class="category-list-link" href="/notes-on-computer-expertise/categories/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/">数据结构</a></li><li class="category-list-item"><a class="category-list-link" href="/notes-on-computer-expertise/categories/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86/">数据结构基础知识</a></li><li class="category-list-item"><a class="category-list-link" href="/notes-on-computer-expertise/categories/%E6%A8%A1%E6%9D%BF/">模板</a></li><li class="category-list-item"><a class="category-list-link" href="/notes-on-computer-expertise/categories/%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0/">深度学习</a></li><li class="category-list-item"><a class="category-list-link" href="/notes-on-computer-expertise/categories/%E8%8B%B1%E8%AF%AD/">英语</a></li><li class="category-list-item"><a class="category-list-link" href="/notes-on-computer-expertise/categories/%E8%99%9A%E5%B9%BB4/">虚幻4</a></li><li class="category-list-item"><a class="category-list-link" href="/notes-on-computer-expertise/categories/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86/">计算机组成原理</a></li><li class="category-list-item"><a class="category-list-link" href="/notes-on-computer-expertise/categories/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C/">计算机网络</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tags</h3>
    <div class="widget">
      <ul class="tag-list" itemprop="keywords"><li class="tag-list-item"><a class="tag-list-link" href="/notes-on-computer-expertise/tags/C/" rel="tag">C++</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tag Cloud</h3>
    <div class="widget tagcloud">
      <a href="/notes-on-computer-expertise/tags/C/" style="font-size: 10px;">C++</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/notes-on-computer-expertise/archives/2022/05/">May 2022</a></li><li class="archive-list-item"><a class="archive-list-link" href="/notes-on-computer-expertise/archives/2022/03/">March 2022</a></li><li class="archive-list-item"><a class="archive-list-link" href="/notes-on-computer-expertise/archives/2022/02/">February 2022</a></li><li class="archive-list-item"><a class="archive-list-link" href="/notes-on-computer-expertise/archives/2022/01/">January 2022</a></li><li class="archive-list-item"><a class="archive-list-link" href="/notes-on-computer-expertise/archives/2021/12/">December 2021</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/notes-on-computer-expertise/2022/05/31/vue/%E5%89%8D%E7%AB%AF%E6%A1%86%E6%9E%B6%E9%AA%8C%E8%AF%81%E7%A0%81%E6%97%A0%E6%B3%95%E6%98%BE%E7%A4%BA/">(no title)</a>
          </li>
        
          <li>
            <a href="/notes-on-computer-expertise/2022/05/26/%E6%95%B0%E6%8D%AE%E5%BA%93/navicat%E5%AE%89%E8%A3%85/">(no title)</a>
          </li>
        
          <li>
            <a href="/notes-on-computer-expertise/2022/05/25/%E8%99%9A%E5%B9%BB4%E5%BC%95%E6%93%8E%E5%BC%80%E5%8F%91/%E8%99%9A%E5%B9%BB%E5%9B%9B%20mod%E5%88%B6%E4%BD%9C/">(no title)</a>
          </li>
        
          <li>
            <a href="/notes-on-computer-expertise/2022/05/23/python/python%E6%89%B9%E9%87%8F%E7%94%9F%E6%88%90%E6%95%B0%E6%8D%AE/">(no title)</a>
          </li>
        
          <li>
            <a href="/notes-on-computer-expertise/2022/05/23/vba%E5%9F%BA%E7%A1%80%E6%93%8D%E4%BD%9C%E7%AC%94%E8%AE%B0/EXCEL%E5%9F%BA%E7%A1%80%E6%95%99%E7%A8%8B/">(no title)</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      
      &copy; 2022 John Doe<br>
      Powered by <a href="https://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>

    </div>
    <nav id="mobile-nav">
  
    <a href="/notes-on-computer-expertise/" class="mobile-nav-link">Home</a>
  
    <a href="/notes-on-computer-expertise/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    


<script src="/notes-on-computer-expertise/js/jquery-3.4.1.min.js"></script>



  
<script src="/notes-on-computer-expertise/fancybox/jquery.fancybox.min.js"></script>




<script src="/notes-on-computer-expertise/js/script.js"></script>





  </div>
<script type="text/x-mathjax-config">
    MathJax.Hub.Config({
        tex2jax: {
            inlineMath: [ ["$","$"], ["\\(","\\)"] ],
            skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code'],
            processEscapes: true
        }
    });
    MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax();
        for (var i = 0; i < all.length; ++i)
            all[i].SourceElement().parentNode.className += ' has-jax';
    });
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML"></script>
</body>
</html>